<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * @author Lukas Fritsch <jejanim@gmail.com>
 */
class User extends CPT_Controller{
    function __construct(){
	parent::__construct();
    }
    
    /*
     * No direct access allowed, redirect to home page if no further methods are called
     */
    public function index(){
	redirect('start');
    }
    
    /*
     * Shows user details
     * 
     * @param
     */
    public function details($user_id = FALSE){	
        if(FALSE === $user_id)
            redirect('start');
        
        $this->view_data['user'] = Model\User::with('drink', 'contactdata')->find($user_id);
    }
    
    /**
     * 
     */
    public function drinks($user_id = FALSE){
        if(FALSE === $user_id)
            redirect('start');
        
        $this->view_data['user']   = Model\User::find($user_id);
        $this->view_data['drinks'] = $this->view_data['user']->drink();
        
        $this->headline = $this->view_data['user']->username . "'s recipes";
    }
}
